<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>固化工位撤销</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<style type="text/css">
		 .left-label {
		 	width: 120px !important
		 }
	</style>
	<link rel="stylesheet" href="${pageContext.request.contextPath }/assets/css/layui.css"  media="all">
	<link rel="stylesheet" href="${pageContext.request.contextPath }/assets/css/toastr.min.css"  media="all">
</head>
<body>
<div class="demoTable" style="padding:10px 0 0 15px">
	<div class="layui-form-item">
		<div class="layui-inline">
			<label class="layui-form-label">膜管条码</label>
		    <div class="layui-inline">
		    	<input class="layui-input" name="searchStube" id="searchStube" >
		    </div>
	    </div>
	    <div class="layui-inline">
			<label class="layui-form-label">台车条码</label>
		    <div class="layui-inline">
		    	<input class="layui-input" name="searchCremark" id="searchCremark">
		    </div>
	    </div>
   	 <button class="layui-btn layui-btn-blue" style="margin: 0 0 0 10px" data-type="reload"><i class="layui-icon layui-icon-search">  搜索</i></button>
	 </div>
</div>

<table class="layui-hide" id="tableList" lay-filter="tableList"></table>

<script type="text/html" id="toolbar">
	<div class="layui-btn-container">
		<button class="layui-btn layui-btn-blue" lay-event="delete"><i class="layui-icon layui-icon-delete">撤消绑定</i></button>
		<button class="layui-btn layui-btn-blue" lay-event="editStart"><i class="layui-icon layui-icon-delete">撤消开始</i></button>
		<button class="layui-btn layui-btn-blue" lay-event="editEnd"><i class="layui-icon layui-icon-delete">撤消结束</i></button>
	</div>
</script>
 

<script src="${pageContext.request.contextPath }/assets/layui.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath }/assets/layui.all.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath }/assets/js/jquery.min.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath }/assets/js/toastr.min.js" charset="utf-8"></script>

<script type="text/javascript">

	layui.use(['table','layer','upload','form','laydate'], function(){
		var table = layui.table;
		var layer = layui.layer;
		var laydate = layui.laydate;
	    var form = layui.form;
	    
		var $ = layui.jquery, active = {
			reload:function () {
				var searchStube = $("#searchStube").val();
				var searchCremark = $("#searchCremark").val();
				table.reload('contenttable',{
					method:'get',
					where:{"stube":searchStube,"cremark":searchCremark}
				});
			}
		}
		
		$('.layui-btn').on('click', function(){
	        var type = $(this).data('type');
	        active[type] ? active[type].call(this) : '';
	    });
		
		table.render({
		    elem: '#tableList'
		    ,url:'${pageContext.request.contextPath }/solid/getList.do'
		    ,toolbar: '#toolbar'
		    ,title: '工作派遣单'
		    ,id :'contenttable'
		    ,limits:[10,20,30]
		    ,cols: [[
				      {type: 'checkbox', fixed: 'left'},
				      {field:'stube', title:'膜管条码'},
				      {field:'cremark', title:'台车条码'},
				      {field:'cremark1', title:'绑定时间'},
				      {field:'starttime', title:'开始时间'},
				      {field:'startoperator', title:'开始操作人'},
				      {field:'endtime', title:'结束时间'},
				      {field:'endoperator', title:'结束操作人'},
				      //{fixed:'right', title:'操作', toolbar: '#rowToolbar', width:160}
				    ]],
		    page: true,
		});
		
		
	//头工具栏事件
	table.on('toolbar(tableList)', function(obj){
		var checkStatus = table.checkStatus(obj.config.id);
	    switch(obj.event){
	    	case 'editStart':
	    		var data = checkStatus.data;
	        	var idArr = new Array();
	        	if(data.length==0){
	        		toastr.warning("请至少选择一条记录！");
	        	}else {
	        		var ids = "";
		        	for(var i=0;i<data.length;i++){
		        		 if(i != data.length-1) {
			        	 	ids +=data[i].id+",";
			        	 }else {
			        	 	ids +=data[i].id;
			        	 }
		        	}
		        	layer.confirm('确定撤销吗？', function(index){
				        $.ajax({
					    	type:'post',
					    	url:'${pageContext.request.contextPath }/solid/editStart.do',
					    	data:{"ids":ids},
					    	success:function(data){
					    		if(data > 0){
					    			toastr.success("撤销成功！");
					    			setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
										window.location.reload();  
									},2000);
					    		}else{
					    			toastr.warning("撤销失败！");
					    		}
					    	}
					    })
		        	})
	        	}
	      	break;
	    	case 'editEnd':
	    		var data = checkStatus.data;
	        	var idArr = new Array();
	        	if(data.length==0){
	        		toastr.warning("请至少选择一条记录！");
	        	}else {
	        		var ids = "";
		        	for(var i=0;i<data.length;i++){
		        		 if(i != data.length-1) {
			        	 	ids +=data[i].id+",";
			        	 }else {
			        	 	ids +=data[i].id;
			        	 }
		        	}
		        	layer.confirm('确定撤销吗？', function(index){
				        $.ajax({
					    	type:'post',
					    	url:'${pageContext.request.contextPath }/solid/editEnd.do',
					    	data:{"ids":ids},
					    	success:function(data){
					    		if(data > 0){
					    			toastr.success("撤销成功！");
					    			setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
										window.location.reload();  
									},2000);
					    		}else{
					    			toastr.warning("撤销失败！");
					    		}
					    	}
					    })
		        	})
	        	}
	      	break;
	    	case 'delete':
	        	var data = checkStatus.data;
	        	var idArr = new Array();
	        	if(data.length==0){
	        		toastr.warning("请至少选择一条记录！");
	        	}else {
	        		var ids = "";
		        	for(var i=0;i<data.length;i++){
		        		 if(i != data.length-1) {
			        	 	ids +=data[i].id+",";
			        	 }else {
			        	 	ids +=data[i].id;
			        	 }
		        	}
		        	layer.confirm('确定撤销吗？', function(index){
				        $.ajax({
					    	type:'post',
					    	url:'${pageContext.request.contextPath }/solid/delete.do',
					    	data:{"ids":ids},
					    	success:function(data){
					    		if(data > 0){
					    			toastr.success("撤销成功！");
					    			setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
										window.location.reload();  
									},2000);
					    		}else{
					    			toastr.warning("撤销失败！");
					    		}
					    	}
					    })
		        	})
	        	}
	      	break;
	      	case 'select':
	      		console.log(obj)
	      	break;
	    };
	});
  
  //时间检索
    laydate.render({
      elem: '#starttime',
      type: 'datetime',
      format: 'yyyy-MM-dd HH:mm:ss'
    });
});

toastr.options.positionClass = 'toast-top-center'; //提示框的位置设置为中上
</script>

</body>
</html>